package com.h2cloud.JUCTest;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @Package: com.h2cloud.JUCTest
 * @ClassName: testInter
 * @Author: wulongkai
 * @CreateTime: 2024/1/12 15:12
 * @Description:
 */
public class testInter {
    public static void main(String[] args) throws InterruptedException {
        ArrayBlockingQueue arrayBlockingQueue = new ArrayBlockingQueue(10);
        Thread thread = new Thread(() -> {
            System.out.println("开始获取数据");
            try {
                arrayBlockingQueue.poll(10L, TimeUnit.SECONDS);
                System.out.println("获取数据成功");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread.interrupt();
        Thread.sleep(2000);

        System.out.println("main 执行打断");
        thread.start();
        Thread.sleep(5000);
        System.out.println("main 执行打断结束");
        thread.join();
    }
}
